package regexInput;

import java.io.Serializable;
import java.util.ArrayList;

public class TableNode implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -3491030917808319666L;
	//put NFA-necessary related stuff here
	
	//put DFA-necessary related stuff here
	private ArrayList<String> nfaList;
	//basic/similar functionality here
	private ArrayList<ArrayList<String>> transitions;
	private int state;		//0 for starting state, 1 for end state, -1 otherwise
	private String name;	//if applicable
	
	public TableNode(String stateName, int status){
		state = status;
		transitions = new ArrayList<ArrayList<String>>();
		setName(stateName);
	}
	
	public TableNode(int status){
		state = status;
		transitions = new ArrayList<ArrayList<String>>();
		setName("");
	}
	
	public void addTransition(int index, String trans){
		transitions.get(index).add(trans);
	}
	
	public ArrayList<String> getTransitions(int index){
		return transitions.get(index);
	}
	
	public void setState(int status){
		state = status;
	}
	
	public int getState(){
		return state;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	//DFA Methods here
	public void setNFAState(ArrayList<String> list){;
	nfaList = list;
	}

	public void addNFAState(String state){;
		nfaList.add(state);
	}
	
	public void setTransitions(ArrayList<ArrayList<String>> trans){
		this.transitions=trans;
	}
	
	public ArrayList<String> getNFAList() {
		return nfaList;
	}
	
	public String toString(){
		String s = "\t" + name + "\t";
		for(int i = 0; i < transitions.size(); i ++){
			s += "|\t";
			for(String element : transitions.get(i)){
				s += element;
				s += ", ";
			}
			s+= "\t";
		}
		s += "|\n";
		return s;
	}
}
